import { each } from 'lodash'

const filters = {
  truncate(str = '', len) {
    if (str.length <= len) {
      return str
    }
    return `${str.substring(0, len)}...`
  }
}

export default {
  install(Vue) {
    each(filters, (fn, name) => {
      Vue.filter(name, fn)
    })
  }
}